import datetime

from mongoengine import Document, StringField, DictField, DateTimeField, ListField
from pip._internal.cli.status_codes import SUCCESS
from pydantic import BaseModel

from app.core.return_info import FAILED


class WfJournalPageId(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=10, primary_key=True)
    down_date = StringField(max_length=20)
    jsondicts = DictField()
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WFJournalPageIdModel(BaseModel):
    cid: str
    down_date: str
    jsondicts: dict


class WfJournalIssue(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    down_date = StringField(max_length=20)
    jsonlists = ListField()
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WFJournalIssueModel(BaseModel):
    cid: str
    down_date: str
    jsonlists: list = []


class WfJournalArticleInfo(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    down_date = StringField(max_length=20)
    page = StringField(max_length=20)
    jsondicts = DictField()
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WfJournalArticleInfoModel(BaseModel):
    cid: str
    down_date: str
    page: str
    jsondicts: dict


class WfJournalArticle(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    down_date = StringField(max_length=20)
    jsondicts = DictField()
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WfJournalArticleModel(BaseModel):
    cid: str
    down_date: str
    jsondicts: dict


class WfJournalRel(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    down_date = StringField(max_length=20)
    jsondicts = DictField()
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WfJournalRelModel(BaseModel):
    cid: str
    down_date: str
    jsondicts: dict


class WfJournalRef(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    rawid = StringField(max_length=50)
    down_date = StringField(max_length=20)
    jsondicts = DictField()
    ref_cnt = StringField(max_length=10)
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WfJournalRefModel(BaseModel):
    cid: str
    rawid: str
    down_date: str
    jsondicts: dict
    ref_cnt: str


class WfJournalRefOld(Document):
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    rawid = StringField(max_length=50)
    down_date = StringField(max_length=20)
    html = StringField()
    ref_cnt = StringField(max_length=10)
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())


class WfJournalRefOldModel(BaseModel):
    cid: str
    rawid: str
    down_date: str
    html: str
    ref_cnt: str


class WfJournalArticleNew(Document):
    """
    改版后的万方期刊详情页, 以前的是来着issue的列表获取
    现在改版 在详情页获取
    """
    meta = {'db_alias': 'db68wfqk'}
    cid = StringField(max_length=50, primary_key=True)
    down_date = StringField(max_length=20)
    jsondicts = DictField()
    create_time = DateTimeField(default=datetime.datetime.now())
    update_time = DateTimeField(default=datetime.datetime.now())

    # bools 传入True or False 给出对应的字符串


bools_string = lambda bools: SUCCESS if bools else FAILED

class WfJournalArticleNewModel(BaseModel):
    cid: str
    down_date: str
    jsondicts: dict


